package com.parkinglot.management.controller;

import com.parkinglot.management.repository.entity.Account;
import com.parkinglot.management.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "个人账户管理")
@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    AccountService accountService;
    @ApiOperation("添加账户")
    @PostMapping
    public Account addAccount(@RequestBody Account account) {
        return accountService.addAccount(account);
    }

    @ApiOperation("删除账户")
    @DeleteMapping
    public void deleteAccount(Account account) {
        accountService.deleteAccount(account);
    }

    @ApiOperation("获取所有账户")
    @GetMapping
    public List<Account> getAccounts() {
        return accountService.getAccounts();
    }
    @ApiOperation("修改账户")
    @PutMapping
    public Account updateAccount(Account account) {
        return accountService.updateAccount(account);
    }
}
